<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>原型</title>
</head>
<body>
  <script>
    function Star (uname,uage) {
      this.uname = uname;
      this.uage = uage;

    }
    /* 将公共的方法存储到原型对象中 避免在内存中开辟两次空间 */
    Star.prototype.sing = function () {
        console.log('会唱歌');
    }
    var ldh = new Star('刘德华',18);
    var zxy = new Star('张学友',20);
    ldh.sing();
    zxy.sing();
  </script>
</body>
</html>